﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ClipperBaseUI.Controls;
using Microsoft.Win32;
using Clipper.BLL;

namespace Clipper.DataManage
{
    /// <summary>
    /// WinImportExport.xaml 的交互逻辑
    /// </summary>
    public partial class WinImportExport : BaseWindow
    {
        public WinImportExport()
        {
            InitializeComponent();
        }
        DetectItems mDetectItemsBll = new DetectItems();
 
        //导入浏览
        private void btnImpBorwse_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFile = new OpenFileDialog();
            bool? result = openFile.ShowDialog();
            if (result != null && result.Value)
            {
                txtImport.Text = openFile.FileName;
            }
        }
        //导出浏览
        private void btnExpBorwse_Click(object sender, RoutedEventArgs e)
        {
            SaveFileDialog saveFile = new SaveFileDialog();
            bool? result = saveFile.ShowDialog();
            if (result != null && result.Value)
            {
                txtExport.Text = saveFile.FileName;
            }
        }
        //开始导出
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            UIHelper.SuccessOrFailTip(mDetectItemsBll.Export(txtExport.Text, txtExportPwd.Text),"Export");
        }
        //开始导入
        private void btnImport_Click(object sender, RoutedEventArgs e)
        {
            bool? res=mDetectItemsBll.Import(txtImport.Text, txtImportPwd.Text);
            if (res != null)
            {
                if (res.Value)
                {
                    UIHelper.SuccessOrFailTip(true, "Import");
                }
                else
                {
                    UIHelper.ShowKeyMessage("ImportPwdWrongTip");
                }
            }
            else
            {
                UIHelper.ShowKeyMessage("TemplateWrongTip");
            }
        }

    }
}
